/* ldw.t  INVENTORY DETAIL BY LOCATION WRITE TRIGGER                  */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :ldw.t                                                   */
/*  Author  :Ben Holmes                                              */
/*  Date    :11/28/95                                                */
/*  !Description : ld_det WRITE trigger program                      */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.5          Last Modified:  03/19/95 BY: BHolmes *J0FY*  */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy     *J12B*  */
/*Revision 8.5          Last Modified:  01/07/97 BY: jpm     *J1DM*  */
/*Revision 9.0          Last Modified:  08/26/98 BY: *M00M* Robert Jensen */
/*Revision 9.0          Last Modified:  03/13/99 BY: *M0BD* Alfred Tan    */
/*Revision 9.1          Last Modified:  08/13/00 BY: *N0KR* myb           */
/*Revision 9.1          Last Modified:  11/14/00 BY: *N0TS* Robert Jensen */
/*                                                                   */
/*********************************************************************/

TRIGGER PROCEDURE FOR WRITE OF LD_DET OLD BUFFER OLD_LD_DET.

/*J12B  if not can-find(first whl_mstr where whl_mstr.whl_act no-lock) */
/*J12B  then leave. */

    {mfdeclre.i }
    define new shared work-table wf_old_ld_det like ld_det.
    define new shared variable w-recid as recid.
    define variable w-file as character format "x(24)".


    /* Warehousing Interface processing */

    WI:
    do:

    /* If there is no active external warehouse, then do not process */
/*J12B*/    if not can-find(first whl_mstr no-lock
/*J12B*/        where whl_mstr.whl_act)
/*J12B*/    then leave WI.

    /* If no pertinent fields have been changed, then do not process */
/*J12B*/    if   (old_ld_det.ld_part      = ld_det.ld_part
/*J12B*/      and old_ld_det.ld_site      = ld_det.ld_site
/*J12B*/      and old_ld_det.ld_loc       = ld_det.ld_loc
/*J12B*/      and old_ld_det.ld_ref       = ld_det.ld_ref
/*J12B*/      and old_ld_det.ld_lot       = ld_det.ld_lot
/*J12B*/      and old_ld_det.ld_expire    = ld_det.ld_expire
/*J12B*/      and old_ld_det.ld_grade     = ld_det.ld_grade
/*J12B*/      and old_ld_det.ld_assay     = ld_det.ld_assay
/*J12B*/      and old_ld_det.ld_status    = ld_det.ld_status
/*J12B*/      and old_ld_det.ld_user1     = ld_det.ld_user1
/*J12B*/      and old_ld_det.ld_user2     = ld_det.ld_user2)
/*J12B*/    then leave WI.

    /* Move old ld_det values to work table for subsequent processing */
       assign w-recid = recid(ld_det).
       create wf_old_ld_det.
       if recid(wf_old_ld_det)= -1 then .
       assign
           wf_old_ld_det.ld_part      = old_ld_det.ld_part
           wf_old_ld_det.ld_site      = old_ld_det.ld_site
           wf_old_ld_det.ld_loc       = old_ld_det.ld_loc
           wf_old_ld_det.ld_ref       = old_ld_det.ld_ref
           wf_old_ld_det.ld_lot       = old_ld_det.ld_lot
           wf_old_ld_det.ld_expire    = old_ld_det.ld_expire
           wf_old_ld_det.ld_grade     = old_ld_det.ld_grade
           wf_old_ld_det.ld_assay     = old_ld_det.ld_assay
           wf_old_ld_det.ld_status    = old_ld_det.ld_status
           wf_old_ld_det.ld_user1     = old_ld_det.ld_user1
           wf_old_ld_det.ld_user2     = old_ld_det.ld_user2
       .

    /* Call subprogram to create export transactions for warehouse */
        w-file = "wildw.p".
/*J1DM*/ /* {gprun.i ""wildw.p""} */
/*J1DM*/    {gprunmo.i &module="WI"
                       &program="wildw.p"}

/*J12B*/end. /* WI */
/*M00M*//* Logistics Interface processing */
/*N0TS*/ /* Logistics now uses in_mstr, not ld_mstr */
/*N0TS*/ /* Remove further processing from code. */
/*N0TS*
 * /*M00M*/LG:
 * /*M00M*/do:
 * /*M00M*//* If there is no logistics application ID, then do not process */
 * /*M00M*/      if not can-find(first lgs_mstr no-lock
 * /*M00M*/        where lgs_app_id <> "")
 * /*M00M*/           then leave LG.
 * /*M00M*//* If no pertinent fields have been changed, then do not process */
 * /*M00M*/   if (old_ld_det.ld_qty_oh <> ld_det.ld_qty_oh) or
 * /*M00M*/   (old_ld_det.ld_qty_all <> ld_det.ld_qty_all) or
 * /*M00M*/   (old_ld_det.ld_status <> ld_det.ld_status)
 * /*M00M*/   then do:
 * /*M00M*//* Move old ld_det values to work table for subsequent processing */
 * /*M00M*/      if not can-find(first wf_old_ld_det) then do:
 * /*M00M*/         create wf_old_ld_det.
 * /*M00M*/         if recid(wf_old_ld_det)= -1 then .
 * /*M00M*/      end.
 * /*M00M*/      buffer-copy old_ld_det to wf_old_ld_det no-error.
 * /*M00M*//* Call subprogram to publish changed status for Logistics */
 * /*M00M*/      {gprunmo.i &module="LG"
 * /*M00M*/      &program="lgldex.p"
 * /*M00M*/      &param="""(input recid(ld_det))"""}
 * /*M00M*/   end.
 * /*M00M*/end. /* LG */
 *N0TS*/
/*M00M* *End of Added Section */
